<?php

class CatalogController extends Zend_Controller_Action
{
    protected $_isRenderDefault = true;

    public function postDispatch()
    {
        if ($this->_isRenderDefault) {
            $this->render($this->view->catalog()->getScript());
        }
    }

    public function builderAction()
    {

    }

    public function electricAction()
    {

    }

    public function repairAction()
    {
        $this->_isRenderDefault = false;
        $this->view->headTitle('Ремонт инструмента');
        $this->view->listElements = array();
        $this->view->providers = Application_Model_Factory::getRepairProviders();
    }

    public function sanitaryAction()
    {

    }

    public function rentAction()
    {
        $this->view->headTitle('Аренда инструмента');
        $mapper = new Application_Model_Mapper(new Application_Model_DbTable_RentCategory(), new Application_Model_RentCategory());
        $this->view->listElements = $mapper->getCollection(array(), 'category_title ASC');
    }

    public function rentsbycatAction()
    {
        $categoryTranslateTitle = $this->_getParam('category');
        $mapper = new Application_Model_Mapper(new Application_Model_DbTable_Rent(), new Application_Model_Rent());
        $category = $mapper->getRentCategoryBy4pu($categoryTranslateTitle);
        $this->view->headTitle($category->getCategoryTitle());

        if (!$category) {
            $this->_redirect('/rent');
        }

        $this->view->listElements = $mapper->getCollection(array('rent_category' => (int) $category->getId(), 'rent_is_active' => 1), 'rent_priority ASC');
        $this->view->category = $category;
    }
}